<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css"  media="all">
    <link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.min.css" media="all" />
    <link rel="stylesheet" href="__CSS__/admin.css"  media="all">
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
    <style type="text/css">

        /* tooltip */
        #tooltip{
            position:absolute;
            border:1px solid #ccc;
            background:#333;
            padding:2px;
            display:none;
            color:#fff;
        }
    </style>
</head>
<body style="margin: 0 20px">
<fieldset class="layui-elem-field site-demo-button" style="margin-top: 30px;border:0">
    <div class="layui-form-item" style="float: left;">
        <a href="{:url('admin/taglist/createClassify')}" class="layui-btn layui-btn-sm createClassify">
        添加分类
        </a>
    </div>
</fieldset>
<table class="layui-table" lay-even="" lay-skin="row" lay-size="sm">
    <colgroup>
        <col width="150">
        <col width="150">
        <col width="150">
        <col width="150">
        <col width="150">
        <col width="150">
        <col width="150">
        <col width="100">
    </colgroup>
    <thead>
    <tr>
        <th>ID</th>
        <th>栏目名称</th>
        <th>英文名称</th>
        <th>WAP前端展示</th>
        <th>状态</th>
        <th>修改时间</th>
        <th>创建时间</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    {volist name="classify" id="vo"}
    <tr>
        <td>{$vo.classify_id}</td>
        <td>{$vo.classify_name}</td>
        <td>{$vo.classify_en_name}</td>
        <td>
            <form class="layui-form" action="">
                <div class="layui-form-item">
                    <div class="layui-input-block" style="margin:10px">
                        <input type="checkbox" name="show_wap" value="1" data-id="{$vo.classify_id}" lay-filter="changeShowWap" lay-skin="switch" <?php if($vo['classify_status']==1){ echo 'checked';} ?> lay-text="显示|隐藏">
                    </div>
                </div>
            </form>
        </td>
        <td>
            <form class="layui-form" action="">
                <div class="layui-form-item">
                    <div class="layui-input-block" style="margin:10px">
                        <input type="checkbox" name="is_use" value="1" data-id="{$vo.classify_id}" lay-filter="changeUseStatus" lay-skin="switch" <?php if($vo['is_use']==1){ echo 'checked';} ?> lay-text="启用|禁用">
                    </div>
                </div>
            </form>
        </td>
        <td>{$vo.updatetime}</td>
        <td>{$vo.creattime|date='Y-m-d H:i:s',###}</td>
        <td class="operation-menu">
            <a href="{:url('taglist/addclassify',['id'=>$vo.classify_id])}" class="layui-btn layui-btn-xs updClassify"  style="margin-right: 0;font-size:12px;">修改</a>
        </td>
    </tr>
    {/volist}
    </tbody>
</table>

<script src="__PUBLIC__/layui/layui.js" charset="utf-8"></script>
<script src="__PUBLIC__/jquery/jquery.min.js"></script>
<script>
    var message;
    layui.config({
        base: '__JS__/',
        version: '1.0.1'
    }).use(['app', 'message','form'], function() {
        var app = layui.app,
            $ = layui.jquery,
            form = layui.form,
            layer = layui.layer;
        //将message设置为全局以便子页面调用
        message = layui.message;
        //主入口
        app.set({
            type: 'iframe'
        }).init();
        //切换showWap状态
        form.on('switch(changeShowWap)',function(data){
            var id= $(this).attr('data-id')
            var status;
            if(data.elem.checked){
                status =1;
            }else{
                status =2;
            }
            $.ajax({
                url:"{:url('admin/taglist/updateClassifyData')}",
                data:{'id':id,'classify_status':status},
                type:'post',
                async: false,
                success:function(res) {
                    layer.msg(res.msg);
                }
            })
        })
        //切换Use状态
        form.on('switch(changeUseStatus)',function(data){
            var id= $(this).attr('data-id')
            var is_use;
            if(data.elem.checked){
                is_use =1;
            }else{
                is_use =0;
            }
            $.ajax({
                url:"{:url('admin/taglist/updateClassifyData')}",
                data:{'id':id,'is_use':is_use},
                type:'post',
                async: false,
                success:function(res) {
                    layer.msg(res.msg);
                }
            })
        })


        $('.updClassify,.createClassify').click(function(){
            var url = $(this).attr('href');
            layer.open({
                type:2,
                content:url,
                area: ['40%', '60%'],
                end:function(){
                    location.reload();
                }
            });
            return false;
        })
    });
</script>
</body>
</html>
